package com.yhy.wxzn.wcs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yhy.wxzn.wcs.entity.WcsInboundConfig;
import com.yhy.wxzn.wcs.entity.WcsInboundDetail;
import com.yhy.wxzn.wcs.mapper.WcsInboundConfigMapper;
import com.yhy.wxzn.wcs.service.IWcsInboundConfigService;
import com.yhy.wxzn.wcs.service.IWcsInboundDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description: 入库业务配置
 * @Author: jeecg-boot
 * @Date:   2023-11-02
 * @Version: V1.0
 */
@Service("WcsInboundConfigServiceImpl")
@Transactional(rollbackFor = Exception.class)
public class WcsInboundConfigServiceImpl extends ServiceImpl<WcsInboundConfigMapper, WcsInboundConfig> implements IWcsInboundConfigService {

    @Autowired
    private IWcsInboundDetailService inboundDetailService;

    @Override
    public void removeOutConfigBatch(List<String> inboundIds) {
        LambdaQueryWrapper<WcsInboundDetail> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(WcsInboundDetail::getInboundId,inboundIds);
        inboundDetailService.remove(wrapper);
        this.removeByIds(inboundIds);
    }

    @Override
    public WcsInboundConfig getByPortCode(String portCode) {
        LambdaQueryWrapper<WcsInboundConfig> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(WcsInboundConfig::getCode,portCode);
        return getOne(wrapper);
    }
}
